package com.taxshare.purchaser.controller;

import com.taxshare.mybatis.pager.PageRequest;
import com.taxshare.purchaser.entity.ApplicationRecordEntity;
import com.taxshare.purchaser.entity.TollTicketEntity;
import com.taxshare.purchaser.service.ApplicationRecordService;
import com.taxshare.purchaser.view.dto.ApplicationRecordDTO;
import com.taxshare.response.beans.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author YANG
 * @date 2021/4/9
 */
@RestController
@RequestMapping("/applicationRecord")
@Api(tags = "申请记录")
public class ApplicationRecordController {

    @Autowired
    ApplicationRecordService applicationRecordService;

    @PostMapping("/query")
    @ApiOperation(value = "申请记录查询", notes = "申请记录")
    public Response<ApplicationRecordEntity> queryRecord(@RequestBody PageRequest<ApplicationRecordDTO> query) {
        return applicationRecordService.queryRecord(query);
    }

    @PostMapping("/queryReject")
    @ApiOperation(value = "驳回审批查询", notes = "申请记录")
    public Response<ApplicationRecordEntity> queryRejectRecord(@RequestBody PageRequest<ApplicationRecordDTO> query) {
        return applicationRecordService.queryRejectRecord(query);
    }

    @PostMapping("/queryDetail")
    @ApiOperation(value = "发票查看", notes = "申请记录")
    public Response<TollTicketEntity> queryDetail(@RequestBody PageRequest<ApplicationRecordDTO> query) {
        return applicationRecordService.queryDetail(query);
    }

    @PostMapping("/cancel")
    @ApiOperation(value = "撤销申请", notes = "我的申请")
    public Response cancelRecord(@RequestBody ApplicationRecordDTO applicationRecordDTO) {
        return applicationRecordService.cancelRecord(applicationRecordDTO);
    }

    @PostMapping("/approval")
    @ApiOperation(value = "批量审批", notes = "驳回审批")
    public Response approval(@RequestBody List<ApplicationRecordDTO> applicationRecordDTOs) {
        return applicationRecordService.approval(applicationRecordDTOs);
    }

}
